// ***********************************************************************
// Assembly         : TSharp.Core
// Author           : tangjingbo
// Created          : 08-16-2013
//
// Last Modified By : tangjingbo
// Last Modified On : 09-26-2013
// ***********************************************************************
// <copyright file="AttributeValue.cs" company="">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace RazorEngine
{
    using System;

    /// <summary>
    /// Class AttributeValue
    /// </summary>
    public class AttributeValue
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeValue" /> class.
        /// </summary>
        /// <param name="prefix">The prefix.</param>
        /// <param name="value">The value.</param>
        /// <param name="literal">if set to <c>true</c> [literal].</param>
        public AttributeValue(PositionTagged<string> prefix, PositionTagged<object> value, bool literal)
        {
            Prefix = prefix;
            Value = value;
            Literal = literal;
        }

        /// <summary>
        /// Gets the prefix.
        /// </summary>
        /// <value>The prefix.</value>
        public PositionTagged<string> Prefix { get; private set; }
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <value>The value.</value>
        public PositionTagged<object> Value { get; private set; }
        /// <summary>
        /// Gets a value indicating whether this <see cref="AttributeValue"/> is literal.
        /// </summary>
        /// <value><c>true</c> if literal; otherwise, <c>false</c>.</value>
        public bool Literal { get; private set; }

        /// <summary>
        /// Froms the tuple.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>AttributeValue.</returns>
        public static AttributeValue FromTuple(Tuple<Tuple<string, int>, Tuple<object, int>, bool> value)
        {
            return new AttributeValue(value.Item1, value.Item2, value.Item3);
        }

        /// <summary>
        /// Froms the tuple.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>AttributeValue.</returns>
        public static AttributeValue FromTuple(Tuple<Tuple<string, int>, Tuple<string, int>, bool> value)
        {
            return new AttributeValue(value.Item1, new PositionTagged<object>(value.Item2.Item1, value.Item2.Item2), value.Item3);
        }

        /// <summary>
        /// Performs an implicit conversion from <see>
        ///                                          <cref>Tuple{Tuple{System.StringSystem.Int32}Tuple{System.ObjectSystem.Int32}System.Boolean}</cref>
        ///                                      </see>
        ///     to <see cref="AttributeValue"/>.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>The result of the conversion.</returns>
        public static implicit operator AttributeValue(Tuple<Tuple<string, int>, Tuple<object, int>, bool> value)
        {
            return FromTuple(value);
        }

        /// <summary>
        /// Performs an implicit conversion from <see>
        ///                                          <cref>Tuple{Tuple{System.StringSystem.Int32}Tuple{System.StringSystem.Int32}System.Boolean}</cref>
        ///                                      </see>
        ///     to <see cref="AttributeValue"/>.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>The result of the conversion.</returns>
        public static implicit operator AttributeValue(Tuple<Tuple<string, int>, Tuple<string, int>, bool> value)
        {
            return FromTuple(value);
        }
    }
}